<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="../../layui/css/layui.css">
    <style>
        html,
        body {
            height: 100%;
            width: 100%;
            background-image: url('../../images/denglubeijing.jpg');
            background-size: 100%;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: center;
        }

        .denglu {
            background-color: #ffffff;
            width: 390px;
            height: 340px;
            border-radius: 6px;
        }

        .yonghudenglu {
            text-align: center;
            font-size: 20px;
            margin: 30px 0;
            color: #666;
            font-weight: 500;
        }

        .zhanghao {
            width: 84%;
            margin: 30px 0;
            margin-left: 8%;
        }

        .mima {
            width: 84%;
            margin: 30px 0;
            margin-left: 8%;
        }

        .forgetmima {
            margin: -24px 32px;
            color: #666;
            font-weight: normal;
            float: right;
        }

        .dengluanniu {
            background-color: #dd4b39;
            width: 84%;
            margin: 0px 8%;
        }

        .layui-input {
            height: 45px;
            padding-left: 40px;
        }

        .icon {
            position: absolute;
            margin: 11px;
            font-size: 20px;
            color: #909399;
        }

        .layui-btn {
            font-size: 16px;
            height: 45px;
        }
    </style>
</head>

<body>
    <div class="denglu">
        <div class="yonghudenglu">用户登录</div>
        <div class="zhanghao">
            <i class="layui-icon layui-icon-username icon"></i>
            <input type="text" name="zhanghao" required lay-verify="required" placeholder="请输入账号" autocomplete="off"
                class="layui-input zhanghaozhanghao">
        </div>
        <div class="mima">
            <i class="layui-icon layui-icon-password icon"></i>
            <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off"
                class="layui-input mimamima">
        </div>
        <div class="forgetmima">
            <a href="wangjimima.html">忘记密码</a>
        </div>
        <div class="dengluanniu">
            <a class="layui-btn layui-btn-danger dengluanniu">登录</a>
        </div>
    </div>
</body>
<script src="../../layui/layui.js"></script>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<!-- <script src="../../js/layer.js"></script> -->
<script>
    var url = "http://47.105.118.98:9013";
    // 登陆方法

    $('.denglu').keydown(function (e) {
        if (e.keyCode === 13) {
            $(".dengluanniu").trigger("click");
            return false
        }
    });
    $('.dengluanniu').click(function () {
        var zhanghao = $(".zhanghaozhanghao").val(); //账号
        var mima = $(".mimamima").val(); //密码
        $.get(url + "/user/login", {
            username: zhanghao,
            password: mima
        },
            function (data) {
                console.log(data);
                if (data.code == 200) {
                    console.log(data)
                    window.localStorage.setItem("token", data.data.token)
                    window.localStorage.setItem("id", data.data.user.id)
                    window.localStorage.setItem("username", data.data.user.username)
                    window.localStorage.setItem("name", data.data.user.name)
                    if (data.data.user.level == 0) {
                        window.location = '../../index1.html'
                    } else {
                        window.location = '../../index2.html'
                    }
                } else {
                    layui.use(['layer'], function () {
                        layer.msg(data.msg)
                        return false
                    })
                }
            })
    })
</script>

</html>